package com.nd.mobile.study.domain;

import java.lang.reflect.Type;

import android.os.Bundle;

import com.fuckhtc.gson.Gson;
import com.fuckhtc.gson.annotations.SerializedName;
import com.fuckhtc.gson.reflect.TypeToken;
import com.nd.mobile.study.common.config.Commands;
import com.nd.mobile.study.common.config.ReqParam;
import com.nd.mobile.study.common.util.HttpRequestUtil;

public class ClassInfoCatalogRoot {

	@SerializedName("ClassesInfoClassID")
	private String id;
	
	@SerializedName("ClassesInfoClassName")
	private String name;
	
	private String classId;

	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	void setClassId(String classId) {
		this.classId = classId;
	}

	public ClassInfoCatalog[] getClassInfoCatalog(User user) throws Exception {
		Bundle data = new Bundle();
		data.putString(ReqParam.COMMON_USER_ID, user.getUserId());
		data.putString(ReqParam.ClassInfo.CLASSES_ID, classId);
		data.putString(ReqParam.ClassInfo.CLASSES_CATALOG_ROOT_ID, id);
		String jsonData = HttpRequestUtil.get(Commands.GET_CLASS_INFO_CATALOG, data);
		Gson gson = new Gson();
		Type type = new TypeToken<Result<ClassInfoCatalog[]>>(){}.getType();
		Result<ClassInfoCatalog[]> result = gson.fromJson(jsonData, type);
		ClassInfoCatalog[] body = result.getBody();
		return body;
	}
	
}
